package com.csun.cmny.provider.controller.admin;

import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.model.domain.DmcPhoneData;
import com.csun.cmny.provider.model.dto.phone.PhoneDataHiPageQuery;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.DmcPhoneDataHiService;
import com.csun.cmny.provider.service.DmcPhoneDataService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import com.github.pagehelper.PageInfo;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-01-09 16:42
 * @Description: the class dmc phone data controller.
 */
@RestController
@RequestMapping(value = "/phone", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DmcPhoneDataController extends BaseController {

    @Resource
    private DmcPhoneDataService phoneDataService;

    @Resource
    private DmcPhoneDataHiService phoneDataHiService;

    @Resource
    private CmnyMessageSource cmnyMessageSource;

    /**
     * 查询电话机实时数据
     *
     * @param deviceId the device id
     *
     * @return the wrapper
     */
    @RequestMapping(value = "/queryRealPhoneDataByDeviceId/{deviceId}", method = RequestMethod.POST)
    public Wrapper queryRealPhoneDataByDeviceId(@PathVariable Long deviceId) {

        DmcPhoneData dmcPhoneData = phoneDataService.queryRealPhoneDataByDeviceId(deviceId);

       // return WrapMapper.ok(dmcPhoneData);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),dmcPhoneData);
    }

    /**
     * 查询电话机历史数据
     *
     * @param phoneDataHiPageQuery the phone data hi query page
     *
     * @return the wrapper
     */
    @RequestMapping(value = "/queryDmcPhoneDataHiListWithPage", method = RequestMethod.POST)
    public Wrapper queryDmcPhoneDataHiListWithPage(@RequestBody PhoneDataHiPageQuery phoneDataHiPageQuery) {

        PageInfo pageInfo = phoneDataHiService.queryDmcPhoneDataHiListWithPage(phoneDataHiPageQuery);

       // return WrapMapper.ok(pageInfo);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),pageInfo);
    }

}
